package com.wjjun.test.ui

import android.view.View
import androidx.databinding.ViewDataBinding
import com.wjjun.base.ui.fragment.BaseListFragment
import com.wjjun.base.ui.viewmodel.BaseItemViewModel
import com.wjjun.base.ui.viewmodel.BaseViewModel
import com.wjjun.test.ui.itemviewmodel.TestItemViewModel
import com.wjjun.test.ui.viewmodel.TestListFragmentViewModel

/**
 * 列表fragment
 */
class TestListFragment(private val index: Int) :
    BaseListFragment<TestListFragmentViewModel, ViewDataBinding>() {
    override fun initParams() {
        super.initParams()
    }

    override suspend fun fetchData() {
        refreshData()
    }

    override suspend fun fetchData(pageNum: Int, pageSize: Int, useCache: Boolean, param: Any?) {
        val list = ArrayList<BaseItemViewModel<*>>()
        list.add(TestItemViewModel("第${index}个Fragment"))
        for (i in 0..100) {
            list.add(TestItemViewModel("生成${i}"))
        }
        setData(list, pageNum)
    }

    override fun onItemClick(view: View, itemViewModel: BaseViewModel) {
    }

}